import { useMemoizedFn } from 'ahooks'

import { ICusAgGridProps } from '@/components/CusAgGrid'
import { IOrderListItem } from '../interface'
import { setColExtFlags } from './utils'

export const useOnColumnGroupOpened = () => {
  return useMemoizedFn<NonNullable<ICusAgGridProps<IOrderListItem>['onColumnGroupOpened']>>(e => {
    if (!e.columnGroup) {
      return
    }
    setColExtFlags(e.columnGroup.getGroupId(), e.columnGroup.isExpanded())
  })
}
